package luogu.editor;
import java.util.*;
public class B3612 {
    // 求区间和
}
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] pre = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            if(i==0){
                pre[i]=a[i];
            }else{
                pre[i]=pre[i-1]+a[i];
            }
        }
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            System.out.println(pre[r] - (l > 0 ? pre[l - 1] : 0));
        }
    }
}